import JsSha from 'jssha';
import {
  User,
  Company,
  Contract,
} from '../server/data/models';

const sha = new JsSha('SHA3-224', 'TEXT');

const mock = async () => {

  const wico = await Company.create({
    name: "admin",
    email: "admin@wico.sh",
    city: "shanghai",
    address: "some address",
    note: "some note",
  });

  await Promise.all([1,2,3].map(async (i) => {
    await Company.create({
      name: `com${i}`,
      email: `admin@${i},com`,
      city: "beijing",
      address: "address",
      note: "note",
      status: true,
    });
  }));

  console.log('start mocking');
  sha.update("123");
  const adminUser = await User.create({
    name: "admin",
    password: sha.getHash('HEX'),
    email: "cmh@123.com",
    company_id: "1",
  });

  await Promise.all(['aa', 'bb', 'cc'].map(async (i) => {
    await Contract.create({
      name: i,
      company_id: 2,
    })
  }));
};

mock().then(() => {
  console.log('finish mock')
});
